var vm = new Vue({
    el:'#app',
    data:{
        host:'http://127.0.0.1:8000/',
        navinfo:[],
        ficinf:[],
        web_ficinf:[],//首页的图片小说
        videoi:true,
        nav_name:'',
        new_zhang:'',//每个小说的最新章节
        new_tops:[],//右边的最新小说
        hedding:false//隐藏dic,





    },
    mounted:function(){
        this.nav_id =  this.get_query_string('nav_id');
        this.fic()
        this.get_index()
        this.new_top()



    },
    methods:{

         get_query_string: function(name){
            var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
            var r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return decodeURI(r[2])
            }
                return null;
        },



        //获取导航
        fic:function () {
            axios.get(this.host+'nav/',{

            }).then(response=>{

                this.navinfo=response.data


            }).catch(error=>{

            })
        },
        //获取小说名字
        get_fic:function (nav_id,nav_name) {
            axios.get(this.host+'fic/'+nav_id,{

            }).then(response=>{
                this.ficinf = response.data;
                this.nav_name=nav_name.slice(0,2)
                this.web_ficinf = response.data.slice(-6)
                 this.hedding=true

                 this.videoi=false
            }).catch(error=>{

            })

        },
        //到章节页面
        detail:function (fic_id) {
            window.location = 'zhangjie.html?fic_id='+fic_id
            var audio = new Audio('url');
            audio.pause();
        },
        //获取返回的页面
        get_index:function () {
             if (this.nav_id){
             axios.get(this.host+'fic/'+this.nav_id,{

            }).then(response=>{
                this.ficinf = response.data
                this.videoi=false
                 this.web_ficinf = response.data.slice(-6)
                 this.hedding=true//显示图片的
            }).catch(error=>{

            })
             }
        },
        //最新推荐的章节跳转
        todetail:function (todetail_id,fic_id) {
            window.location='detail.html?detail_id='+todetail_id+'&fic_id='+fic_id
        },
        //最新推荐小说
        new_top:function () {
            axios.get(this.host+'new_istop/',{

            }).then(response =>{
                this.new_tops =response.data
            }).catch(error=>{

            })


        },
        //跳转全部小说页面
        allfic:function () {
            window.location='allfic.html'
        }

    }
})